package com.leizhou.springboot.comtroller;

import com.leizhou.springboot.pojo.User;
import com.leizhou.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author LT
 * @version 1.0.0
 * @ClassName UserController.java
 * @Description TODO
 * @createTime 2020年04月16日 22:15:00
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/findAll")
    // @CrossOrigin(origins = {"http://127.0.0.1:9000"})
    public List<User> findAll() {
        return userService.findAll();
    }

    @PostMapping("/save")
    public boolean save(@RequestBody User user) {
        try {
            userService.save(user);
            return true;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return false;
    }

}
 